import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author wq3stone
 */
public class Page2Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int num = 0;
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        try {
            num = Integer.parseInt(req.getParameter("num"));
            req.getSession().setAttribute("num2",num);
            resp.getWriter().print("您输入的数字为："+num);
        } catch (NumberFormatException e) {
            resp.getWriter().print("请不要输入数字以外的字符！");
        }

    }
}
